package com.example.hyw.szysteam.view;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

import com.example.hyw.szysteam.POJO.UserInfo;
import com.example.hyw.szysteam.R;
import com.qmuiteam.qmui.widget.QMUITopBar;

/**
 * Created by HYW on 2018/5/24.
 */

public class UserInfoActivity extends AppCompatActivity {
    TextView infoName;
    TextView infoSchool;
    TextView infoSex;
    TextView infoAge;
    TextView infoEmail;
    QMUITopBar mTopBar;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_userinfo);
        initTopBar();
        initView();
    }

    private void initTopBar(){
        mTopBar=findViewById(R.id.topbar);
        mTopBar.setTitle("个人信息").setTextColor(getResources().getColor(R.color.myWhite));
        mTopBar.addLeftImageButton(R.drawable.ic_left,R.id.left).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        mTopBar.addRightImageButton(R.drawable.ic_edit,R.id.right).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(UserInfoActivity.this,EditInfoActivity.class);
                startActivity(intent);
            }
        });
    }

    private void initView(){
        infoName=findViewById(R.id.info_name);
        infoSchool=findViewById(R.id.info_school);
        infoSex=findViewById(R.id.info_sex);
        infoAge=findViewById(R.id.info_age);
        infoEmail=findViewById(R.id.info_email);
        infoName.setText(UserInfo.getName());
        infoSchool.setText(UserInfo.getSchool());
        if(UserInfo.isSex()){
            infoSex.setText("女");
        }else{
            infoSex.setText("男");
        }
        infoAge.setText(""+UserInfo.getAge());
        infoEmail.setText(UserInfo.getEmail());
    }
}
